export interface SocketMessage<T, K = SocketEventType> {
  event_type: K;
  data: T;
}

export const enum SocketEventType {
  // 普通商品通知
  productNotify = 1,
  // 深度商品通知
  deepProductNotify = 2,
  // 任务商品派发通知
  receiveTaskNotify = 3,
  // 任务商品删除通知
  deleteTaskNotify = 4
}

export interface productNotifyProperties {
  /**
   * 商品名称
   */
  product_name: string;
  /**
   * 核⼼卖点
   */
  sell_point: string;
}

export interface deepProductNotifyProperties {
  /**
   * 视频⽂案
   */
  sell_copy: string;
  /**
   * 视频名称数组
   */
  video_names: string[];
}

export interface taskProperties {
  /**
   * 任务商品id
   */
  id: number;
  /**
   * 商品标题
   */
  product_title: string;
  /**
   * excel 商品ID
   */
  item_id: string;
  /**
   * excel 商品链接
   */
  item_url: string;
  /**
   * excel 销量
   */
  item_saleCon: string;
  /**
   * excel 到手佣金
   */
  item_brokerage: string;
  /**
   * excel 产品类目
   */
  item_category: string;
}

export interface tasksProperties {
  /**
   * 任务
   */
  tasks: taskProperties[];
}

export interface deleteTaskProperties {
  /**
   * 要删除的任务商品id数组
   */
  taskProductIds: number[];
}

export type SocketEventMessage = SocketMessage<
  productNotifyProperties | deepProductNotifyProperties | tasksProperties | deleteTaskProperties
>;

export type SocketEvent =
  | {
      event_type: SocketEventType.productNotify;
      product_id: number;
      data: productNotifyProperties;
    }
  | {
      event_type: SocketEventType.deepProductNotify;
      product_id: number;
      data: deepProductNotifyProperties;
    }
  | {
      event_type: SocketEventType.receiveTaskNotify;
      product_id: number;
      data: tasksProperties;
    }
  | {
      event_type: SocketEventType.deleteTaskNotify;
      product_id: number;
      data: deleteTaskProperties;
    };
